<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>首页--layui后台管理模板 2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="${basePath!}/static/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${basePath!}/static/css/public.css" media="all"/>
    <style>
        #isShowTable{
            display: none;
            bottom: 5px;
            right: 5px;
            position: fixed;
        }
    </style>
</head>
<body class="childrenBody">
<blockquote class="layui-elem-quote layui-bg-green">
    <table style="width: 100%;">
        <tr style="width: 100%;>
            <td style="width: 70%;><div id="nowTime" style="width: 70%;"></div></td>
            <td style="width: 30%;><div style=" width: 30%;">客户跟进<span id="messageCount"></span>条
            </div></td>
        </tr>
    </table>


</blockquote>
<!-- 客户数据-->
<#--<div id="myCustomerGroupData" style="width: 500px;height: 350px;"></div>-->

<script type="text/javascript" src="${basePath!}/static/layui/layui.js"></script>
<script type="text/javascript" src="${basePath!}/static/js/main.js"></script>
<script type="text/javascript" src="${basePath!}/static/jqgrid/js/jquery-1.11.0.min.js"></script>
<#--<script type="text/javascript" src="${basePath!}/static/echarts/echarts.js"></script>
<script type="text/javascript" src="${basePath!}/static/echarts/echarts-all.js"></script>
<script type="text/javascript" src="${basePath!}/static/echarts/chart/bar.js"></script>-->
<!-- 客户数据-->
<script type="text/javascript">
    // 基于准备好的dom，初始化echarts实例
    /*var myChart = echarts.init(document.getElementById('myCustomerGroupData'));
    // 指定图表的配置项和数据
    myChart.setOption({
        title: {
            text: '客户分类统计图'
        },
        tooltip: {},
        legend: {
            data: ['客户分类']
        },
        xAxis: {
            data: ["A","B","C","D"]
        },
        yAxis: {},
        series: [{
            name: '客户分类',
            type: 'bar',
            data: [20,35,18,30]
        }]
    });*/
   /* myChart.showLoading();
    var names=[];    //类别数组（实际用来盛放X轴坐标值）
    var nums=[];    //统计数据（实际用来盛放Y坐标值）
    //请求后台，获取该记录的详细记录，并填充进表单
    $.ajax({
        type: "POST",
        url: "customer/getMyCustomerData",
        //data: {id: ret.id},
        async: false,
        error: function (request) {
            layer.alert("与服务器连接失败/(ㄒoㄒ)/~~");
        },
        success: function (data) {
            if (data.state == 'fail') {
                layer.alert(data.mesg);
                return false;
            }
            if (data.state == 'success') {
                //向echarts填充数据

                for(var i=0;i<data.datamap.length;i++){
                    names.push(data.datamap[i].groupType);    //挨个取出类别并填入类别数组
                }
                for(var i=0;i<data.datamap.length;i++){
                    nums.push(data.datamap[i].dataCount);    //挨个取出销量并填入销量数组
                }
                myChart.hideLoading();    //隐藏加载动画
                // 填入数据
                myChart.setOption({
                    xAxis: {
                        data:names
                    },
                    series: [{
                        // 根据名字对应到相应的系列
                        type: 'bar',
                        name: '客户分类',
                        data: nums
                    }]
                });



            }
        }
    });*/

</script>
<script type="text/javascript">
    var len=0;
    $(function () {
        scroll();
    })
    setTimeout('flash_title()', 2000); //2秒之后调用一次
    function flash_title() {
        //没焦点状态下才闪动
        if (len>0) {
            newMsgCount();
        } else {
            $("#messageCount").text('【0】');//窗口没有消息的时候默认的title内容
            window.clearInterval();
        }
    }
    //消息提示
    var flag = false;
    function newMsgCount() {
        if (flag) {
            flag = false;
            var contentStr="<a href=\"customer/toTrailCustomerManage\" style='color: red;font-size: 16px;' >【"+len+"】</a>"
            $("#messageCount").html(contentStr);
        } else {
            flag = true;
            var content="<a href=\"customer/toTrailCustomerManage\" style='color: #fcff58;font-size: 16px;' >【"+len+"】</a>"
            $("#messageCount").html(content);
        }
        window.setTimeout('flash_title(0)', 380);
    }

    var dt = setInterval(scroll, 300000);
    function scroll(){
        var trStr="";
        //请求后台，执行删除操作
        $.ajax({
            type: "POST",
            url: "customer/messageInfo",
            async: false,
            error: function (request) {
                layer.alert("与服务器连接失败/(ㄒoㄒ)/~~");
            },
            success: function (data) {
                if (data.state == 'fail') {
                    layer.alert(data.mesg);
                }
                if (data.state == 'success') {
                   if (data.message.length>0){
                       len=data.message.length;
                       $("#isShowTable").show();
                       for (var i=0;i<data.message.length;i++) {
                            trStr+="<tr style=\"border:2px solid #000000\"><td style=\"border:2px solid #000000\"><a style='cursor:pointer;' href=\"customer/toTrailCustomerManage\">"+data.message[i].linkman+"</a></td>";
                            trStr+="<td style=\"border:2px solid #000000\">"+data.message[i].tel+"</td>";
                            trStr+="<td style=\"border:2px solid #000000\">"+data.message[i].qq+"</td>";
                            trStr+="<td style=\"border:2px solid #000000\">"+data.message[i].wx+"</td>";
                            trStr+="</tr>";
                       }
                       $("#messgaeInfo").html(trStr);


                   }else{
                       $("#isShowTable").hide();
                   }

                }
            }
        });
    }
</script>
</body>
</html>